package com.wangp.mywrite.util;

import cn.hutool.json.JSONUtil;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;

import java.util.List;
import java.util.stream.Collectors;

/**
 * programName: fitaipolicy
 * fileName: StringUtil
 * author: ltl
 * createTime:2020/3/20 16:51
 */
public class StringUtil {
    /**
     * 将枚举类内容转化为list
     *
     * @param es
     * @return
     */
    public static List<String> splitEnum(String es) {
        return Lists.newArrayList(Splitter.on(',').trimResults().split(es));
    }

    public static String convertJson2DbStr(String json,Class<?> clazz){
        List<?> list = JSONUtil.toList(json, clazz);
        System.out.println(list.size());
        String elements = list.stream().map(Object::toString).collect(Collectors.joining(","));
        return String.format("(%s)", elements);
    }

    public static void main(String[] args) {
        System.out.println(convertJson2DbStr("[225615, 242249, 256856, 268457, 300615, 362936, 412421, 419872, 432069, 433394, 435002, 436065, 436924, 438553, 438908, 439921, 441786, 442070, 442168, 445036, 445467, 446797, 447673, 448179, 449686, 450113, 450389, 451322, 451450, 451500, 451739, 452072, 452098, 452946, 453235, 453506, 453571, 453576, 453931, 453977, 454018, 454591, 454917, 454980, 455018, 455070, 455395, 455421, 455435, 455454, 455492, 455539, 455620, 455740, 455760, 455810, 455812, 455813, 455815, 455817, 455819, 455822, 455824, 455828, 455829, 455831, 455834, 455835, 455836, 455837, 455838, 455840, 455841, 455852, 455860, 455863, 455865, 455866, 455867, 455873, 455877, 455878, 455886, 455897, 455898, 455906, 455914, 455916, 455919, 455923, 455942, 455959, 455960, 455988, 455989, 455993, 456003, 456004, 456005, 456006, 456008, 456013, 456014, 456016, 456020, 456022, 456023, 456026, 456034, 456037, 456042, 456044, 456047, 456057, 456065, 456067, 456068, 456069, 456075, 456076, 456085, 456093, 456098, 456104, 456107, 456108, 456116, 456119, 456121, 456123, 456124, 456126, 456128, 456129, 456131, 456137, 456139, 456141, 456143, 456144, 456146, 456148, 456150, 456152, 456153, 456155, 456158, 456159, 456160, 456163, 456164, 456168, 456170, 456171, 456175, 456176, 456177, 456179, 456180, 456182, 456183, 456185, 456188, 456190, 456193, 456194, 456197, 456200, 456201, 456202, 456203, 456205, 456208, 456214, 456215, 456221, 456224, 456227, 456230, 456233, 456234, 456235, 456236, 456238, 456240, 456243, 456244, 456245, 456246, 456251, 456253, 456254, 456255, 456256, 456258, 456259, 456260, 456263, 456264, 456265, 456271, 456273, 456274, 456276, 456277, 456286, 456287, 456289, 456290, 456293, 456297, 456299, 456303, 456307, 456311, 456313, 456318, 456319, 456321, 456322, 456325, 456326, 456329, 456335, 456340, 456343, 456345, 456352, 456354, 456355, 456357, 456359, 456361, 456362, 456363, 456371, 456374, 456375, 456382, 456383, 456389, 456391, 456394, 456397, 456399, 456405, 456407, 456408, 456409, 456412, 456414, 456417, 456418, 456433, 456437, 456438, 456441, 456443, 456449, 456453, 456456, 456459, 456460, 456461, 456464, 456473, 456475, 456478, 456482, 456485, 456490, 456491, 456492, 456493, 456497, 456498, 456503, 456505, 456508, 456509, 456514, 456515, 456516, 456518, 456521, 456522, 456525, 456528, 456529, 456530, 456533, 456537, 456539, 456540, 456542, 456544, 456545, 456550, 456553, 456554, 456555, 456559, 456560, 456563, 456565, 456567, 456575, 456577, 456580, 456581, 456583, 456584, 456590, 456592, 456593, 456603, 456606, 456612, 456613, 456620, 456621, 456622, 456623, 456625, 456630, 456632, 456634, 456638, 456641, 456643, 456644, 456646, 456649, 456650, 456655, 456657, 456658, 456659, 456660, 456662, 456663, 456664, 456667, 456669, 456671, 456672, 456673, 456674, 456676, 456678, 456680, 456682, 456684, 456686, 456690, 456693, 456694, 456696, 456701, 456702, 456714, 456715, 456720, 456721, 456728, 456729, 456736, 456745, 456747, 456748, 456751, 456753, 456756, 456760, 456764, 456770, 456771, 456772, 456775, 456784, 456785, 456786, 456788, 456789, 456791, 456797, 456798, 456800, 456801, 456803, 456805, 456808, 456809, 456812, 456815, 456823, 456824, 456826, 456834, 456835, 456836, 456842, 456843, 456850, 456857, 456863, 456864, 456867, 456870, 456875, 456876, 456877, 456882, 456885, 456887, 456892, 456893, 456898, 456900, 456903, 456904, 456905, 456910, 456912, 456913, 456914, 456915, 456919, 456921, 456922, 456929, 456933, 456934, 456936, 456939, 456941, 456942, 456945, 456947, 456955, 456958, 456961, 456966, 456971, 456973, 456977, 456984, 456985, 456987, 456989, 456993, 456999, 457002, 457006, 457009, 457014, 457018, 457024, 457025, 457030, 457031, 457034, 457035, 457036, 457043, 457048, 457049, 457052, 457053, 457060, 457061, 457063, 457069, 457079, 457080, 457081, 457083, 457086, 457088, 457090, 457092, 457094, 457097, 457099, 457102, 457103, 457105, 457112, 457113, 457114, 457123, 457124, 457127, 457128, 457135, 457136, 457137, 457139, 457143, 457145, 457146, 457147, 457160, 457162, 457174, 457175, 457176, 457177, 457178, 457190, 457193, 457195, 457201, 457204, 457205, 457207, 457217, 457220, 457221, 457224, 457231, 457233, 457234, 457237, 457243, 457246, 457248, 457249, 457252, 457253, 457260, 457261, 457264, 457271, 457272, 457274, 457276, 457279, 457281, 457284, 457291, 457292, 457294, 457310, 457318, 457320, 457325, 457329, 457334, 457335, 457337, 457339, 457341, 457344, 457345, 457347, 457348, 457355, 457356, 457359, 457360, 457366, 457370, 457372, 457378, 457379, 457380, 457388, 457391, 457395, 457396, 457398, 457401, 457406, 457407, 457414, 457419, 457422, 457423, 457424, 457425, 457428, 457434, 457435, 457440, 457446, 457449, 457454, 457455, 457460, 457463, 457464, 457477, 457481, 457482, 457484, 457486, 457491, 457496, 457497, 457504, 457522, 457523, 457525, 457528, 457529, 457531, 457546, 457551, 457559, 457560, 457561, 457563, 457565, 457571, 457573, 457575, 457581, 457682, 457728, 457755, 457809, 457892, 457958, 457968, 457976, 457994]", Integer.class));
    }
}
